package test;

import java.util.concurrent.atomic.AtomicInteger;

/**
 * Created by yangyang on 2017/6/8 17:58.
 */
public class TryThreadLocal {

    private static AtomicInteger nextId = new AtomicInteger(0);

    private static ThreadLocal<Integer> threadId = ThreadLocal.withInitial(() -> nextId.getAndIncrement());

    public static int get() {
        return threadId.get();
    }

    public static void main(String[] args) {
        System.out.println(get());
    }
}
